1. Field of the Invention
This invention relates to mapping of data to objects in an object-oriented environment.
2. Background Art
In a database management system (DBMS), data is stored in rows of tables. Each row contains one or more fields or columns. Each column contains an item of data. For example, an employee table contains rows of employee records. Each row, or record, contains information regarding an employee. An employee record can contain, for example, a last name column that contains a last name of the employee.
Data stored in a column of a table can form the basis of a relationship between another table in the database having a related column. A relationship can also be formed using more than one column per table. Using a relationship between columns of two tables, it is possible to join these two tables to provide a single table containing instances of rows from one table combined with related rows from the other table.
Data from two or more tables can also be joined using another capability provided in a DBMS known as a view. A view provides the ability to create a virtual table. That is, the table created using a view is not considered an actual table. Therefore, some DBMS operations, such as update, cannot be performed on a view.
Like a joined table, a view contains rows from one or more tables in the database. For example, a view can contain the rows from two tables in the database, an employee and department table. Such a view may include all or some subset of the total number of columns contained in each of these tables. For example, the employee table contains "employee identification", "department identification", "last name", "first name", "street address", "city", and "zip code" columns. The department table contains "department identification", "description", "number of employees", and "budget" columns. All of the information contained in these two tables may not be pertinent or required to allow a user to be able to review employee information. For example, a department's budget figures are not pertinent to such a system. A view can be used to define a virtual table comprised of the columns in the employee table and the employee's department description from the department table. The "department identification" columns from the two tables can be used to join rows from the two tables to form the view.
Views are useful to simplify the database schema by creating subsets of the database for use with particular applications. Further, views can be used to provide security. In the above example, the exclusion of the "budget" column from the view limits accessibility or knowledge that such a column exists. Thus, a user is only made aware of the data that the user is authorized to access. One disadvantage of views is that they are read-only. Therefore, a view cannot be used to update the base tables that actually contain the data used to create a view.
Another disadvantage of views is that a DBMS restricts the operations that are required to create a view. That is, only someone with database administrator (DBA) privileges can create the virtual tables needed to map objects to the tables of the DBMS. Therefore, to develop an application including views, it is necessary to have someone with DBA privileges available throughout the development phase to make changes to existing views and create new views. Once an application that includes views is distributed to a user site, it is necessary to install the application at the user site. To install the application at the user site, someone with DBA privileges must create the views that are required by the application.
Applications are developed to provide a user with the ability to facilitate access and manipulation of the data contained in a DBMS. A DBMS includes a Data Manipulation Language (DML) such as Structured Query Language (SQL). A DML provides set-oriented relational operations for manipulating data in the DBMS. However, a DML requires a precise syntax that must be used to access and manipulate DBMS data. To use a DML, a user must understand and use the DML's syntax. Instead of requiring each user that wishes to modify a DBMS' data to learn the DML's syntax, applications are written that provide an interface between the user and a DBMS' DML.
Therefore, applications are developed that provide a user interface that allows a user to specify operations to be performed on DBMS data in a more user-friendly manner. These applications are written in a programming language such as C, objective C, and SmallTalk, for example. SQL, or another database programming language, is embedded in these general-purpose programming languages. Once a user identifies a data operation, the application uses embedded SQL statements to perform the operations on the DBMS data as directed by the user.
Some general-purpose programming languages, such as objective C and SmallTalk, are referred to as object-oriented programming languages. Object-oriented programming languages define data and the operations that can be performed on the data. Such a definition is referred to as an object. To use data stored in a DBMS in an application written in an object-oriented language, it is necessary to read data stored in the DBMS as columns within rows of a record into objects. Conversely, object data must be read from the object and stored in tables in the DBMS.
A mapping must be performed to determine what DBMS data is stored in what object, or conversely, what object data is stored in what DBMS tables. There are several disadvantages with the current object-oriented systems' techniques for mapping DBMS data to objects. First, data-to-object mapping must be represented in the program code of an application. That is, an application developer must be aware of the DBMS structure or schema and how the schema is to be mapped onto the application's objects to develop an application. Further, an application must include code to define the mapping. Therefore, the DBMS-to-object mapping is not transparent to the user (e.g., the application developer). Further, the program code needed to implement this mapping increases the size and complexity of the application. The increased coding results in an increase in the amount of the effort needed to debug and maintain the program code. Further, the DBMS-to-object mapping is not dynamic. When a change is made to the DBMS schema, the application must be re-coded to reflect the schema change.
Another disadvantage relates to the restrictions that are placed on the DBMS schema and/or DBMS-to-object mapping that can be supported by the current object-oriented systems. Using current systems, there must be a one-to-one correspondence between an object and a table in the DBMS. Therefore, the schema chosen for the DBMS data is restricted by the object definitions, or vice versa.
Further, because there must be a one-to-one correspondence between a table and object, it is not possible to map multiple tables to a single object. Thus, in the example described above, it is not possible to map the columns included in the virtual table (i.e., columns from the employee table plus the employee's department description from the department table) to the properties of a single object.